#ifndef _HANDLE_TYPE_H_
#define _HANDLE_TYPE_H_

#include "tchar.h"
#include "atlstr.h"

namespace LeaksDebugger
{
	enum ReDefGdiType
	{
		GDI_ICON = 0,
		GDI_CURSOR,
		GDI_BITMAP,
		GDI_BRUSH,
		GDI_COLORSPACE,
		GDI_DC,
		GDI_ENHMETADC,
		GDI_ENHMETAFILE,
		GDI_EXTPEN,
		GDI_FONT,
		GDI_MEMDC,
		GDI_METAFILE,
		GDI_METADC,
		GDI_PAL,
		GDI_PEN,
		GDI_REGION,
	};
};

typedef struct HandleRecoder
{
	TCHAR TypeName[256];
	unsigned int Count;
	
	HandleRecoder()
	{
		memset(this , 0 , sizeof (HandleRecoder));
	}
};

inline void InitGdiHandleRecoders(HandleRecoder (&Recoders)[LeaksDebugger::GDI_REGION+1] )
{
	memset(&Recoders, 0, sizeof(Recoders));
	
	_tcscpy(Recoders[LeaksDebugger::GDI_ICON].TypeName , _T("Icon"));
	_tcscpy(Recoders[LeaksDebugger::GDI_CURSOR].TypeName,  _T("Cursor"));
	_tcscpy(Recoders[LeaksDebugger::GDI_BITMAP].TypeName, _T("Bitmap"));
	_tcscpy(Recoders[LeaksDebugger::GDI_BRUSH].TypeName, _T("Brush"));
	_tcscpy(Recoders[LeaksDebugger::GDI_COLORSPACE].TypeName, _T("Color space"));
	_tcscpy(Recoders[LeaksDebugger::GDI_DC].TypeName, _T("Device context"));
	_tcscpy(Recoders[LeaksDebugger::GDI_ENHMETADC].TypeName, _T("Enhanced metafile DC"));
	_tcscpy(Recoders[LeaksDebugger::GDI_ENHMETAFILE].TypeName, _T("Enhanced metafile"));
	_tcscpy(Recoders[LeaksDebugger::GDI_EXTPEN].TypeName, _T("Extended pen"));
	_tcscpy(Recoders[LeaksDebugger::GDI_FONT].TypeName, _T("Font"));
	_tcscpy(Recoders[LeaksDebugger::GDI_MEMDC].TypeName, _T("Memory DC"));
	_tcscpy(Recoders[LeaksDebugger::GDI_METAFILE].TypeName, _T("Metafile"));
	_tcscpy(Recoders[LeaksDebugger::GDI_METADC].TypeName,  _T("Metafile DC"));
	_tcscpy(Recoders[LeaksDebugger::GDI_PAL].TypeName, _T("Palette"));
	_tcscpy(Recoders[LeaksDebugger::GDI_PEN].TypeName, _T("Pen"));
	_tcscpy(Recoders[LeaksDebugger::GDI_REGION].TypeName, _T("Region"));
}

inline void RecordGDIHandleType( CString& sType,  HandleRecoder (&Recoders)[LeaksDebugger::GDI_REGION+1] )
{
	CString csType;
    if( sType == _T("Icon") ) {
		Recoders[LeaksDebugger::GDI_ICON].Count ++;
    }
    else if( sType == _T("Cursor") ){
		Recoders[LeaksDebugger::GDI_CURSOR].Count ++;
	}
	else if (sType == _T("Bitmap")){
		Recoders[LeaksDebugger::GDI_BITMAP].Count ++;	
	}
	else if (sType == _T("Brush")){
		Recoders[LeaksDebugger::GDI_BRUSH].Count ++;
	}
	else if (sType == _T("Color space")){
		Recoders[LeaksDebugger::GDI_COLORSPACE].Count ++;
	}
	else if (sType == _T("Device context")){
		Recoders[LeaksDebugger::GDI_DC].Count ++;
	}
	else if (sType == _T("Enhanced metafile DC")){
		Recoders[LeaksDebugger::GDI_ENHMETADC].Count ++;
	}
	else if (sType == _T("Enhanced metafile")){
		Recoders[LeaksDebugger::GDI_ENHMETAFILE].Count ++;
	}
	else if (sType == _T("Extended pen")){
		Recoders[LeaksDebugger::GDI_EXTPEN].Count ++;
	}
	else if (sType == _T("Font")){
		Recoders[LeaksDebugger::GDI_FONT].Count ++;
	}
	else if (sType == _T("Memory DC")){
		Recoders[LeaksDebugger::GDI_MEMDC].Count ++;
	}
	else if (sType == _T("Metafile")){
		Recoders[LeaksDebugger::GDI_METAFILE].Count ++;
	}
	else if (sType == _T("Metafile DC")){
		Recoders[LeaksDebugger::GDI_METADC].Count ++;
	}
	else if (sType == _T("Palette")){
		Recoders[LeaksDebugger::GDI_PAL].Count ++;
	}
	else if (sType == _T("Pen")){
		Recoders[LeaksDebugger::GDI_PEN].Count ++;
	}
	else if (sType == _T("Region")){
		Recoders[LeaksDebugger::GDI_REGION].Count ++;
	}
	else
	{
		//nothin to do
	}

}


#endif //_HANDLE_TYPE_H_